package com.yaozheng.vocationaltraining.fragment;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.OnActivityResult;
import org.androidannotations.annotations.ViewById;

import android.app.LocalActivityManager;
import android.content.Intent;
import android.support.v4.view.ViewPager;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TextView;

import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.adapter.IntegralRuleAdapter;

/**
 * 积分规则
 * 
 * @author Administrator
 * 
 */
@EFragment(R.layout.fragment_integral_rule)
public class IntegralRuleFragment extends BaseFragment {
	@ViewById
	ViewPager viewPager;
	@ViewById
	TextView tabItemIntegralRuleText1, tabItemIntegralRuleText2;
	@ViewById
	TextView headTitleText;

	@AfterViews
	public void initView() {
		headTitleText.setText("积分规则");
		viewPager
				.setAdapter(new IntegralRuleAdapter(getChildFragmentManager()));
		viewPager
				.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
					@Override
					public void onPageSelected(int position) {
						IntegralRuleFragment.this.onPageSelected(position);
					}
				});
		onPageSelected(0);
	}

	/**
	 * pageView Item 选中
	 * 
	 * @param position
	 */
	public void onPageSelected(int position) {
		if (position == 0) {
			/**
			 * 第一张选中
			 */
			tabItemIntegralRuleText1.setSelected(true);
			tabItemIntegralRuleText2.setSelected(false);
		} else {
			/**
			 * 第二张选中
			 */

			tabItemIntegralRuleText1.setSelected(false);
			tabItemIntegralRuleText2.setSelected(true);
		}
	}

	/**
	 * 第一个点击
	 */
	@Click(R.id.tabItemIntegralRuleText1)
	public void tabItemIntegralRuleText1Click() {
		viewPager.setCurrentItem(0);
	}

	/**
	 * 第二个点击
	 */
	@Click(R.id.tabItemIntegralRuleText2)
	public void tabItemIntegralRuleText2Click() {
		viewPager.setCurrentItem(1);
	}

}
